package com.chenhao.springcloud.chenhaodesignservice.pattern.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 *
 * @author chenhao
 * @date 2020/12/28 10:20
 */
public class CourseCatalog  extends CatalogComponent{
    private List<CatalogComponent> items = new ArrayList <CatalogComponent>();
    private String name;

    public CourseCatalog(String name) {
        this.name = name;
    }

    @Override
    public void add(CatalogComponent catalogComponent) {
        items.add(catalogComponent);
    }

    @Override
    public void remove(CatalogComponent catalogComponent) {
        items.remove(catalogComponent);
    }

    @Override
    public void print() {
        for (CatalogComponent catalogComponent:items){
         catalogComponent.print();
        }
    }
}
